﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DevExpress.Mvvm;
using orm.Models;

namespace OneStress.PropertyNodes
{
    internal class WellNode : PropertyNode<TgsTDWell>
    {
        public WellNode(Guid id)
        {
            var dbContext = ServiceContainer.Default.GetService<IDisposable>("DBSerice") as OneSysDBContext;

            var query = from w in dbContext.TgsTDWell join d in dbContext.TgsTDWellDatum on w.WellId equals d.WellId  select new { w, d};
            var data  = query.Distinct();
            //_current = data.First().w;


        }

        [Category("General")]
        public override string Name
        {
            get
            {
                
                return _current?.WellCommonName;
            }
            set
            {
                _current.WellCommonName = value;
            }
        }

        [Category("General")]
        public string LegalName
        {
            get
            {
                return _current?.WellLegalName;
            }
            set
            {
                _current.WellLegalName = value;
            }
        }

        [Category("General")]
        public string Description
        {
            get
            {
                return _current?.WellDesc;
            }
            set
            {
                _current.WellDesc = value;
            }
        }


        [Category("General")]
        public string Location
        {
            get
            {
                return _current?.WellGeometry;
            }
            set
            {
                _current.WellDesc = value;
            }
        }


        [Category("Location")]
        public string Country
        {
            get
            {
                return _current?.LocCountry;
            }
            set
            {
                _current.LocCountry = value;
            }
        }


        [Category("Location")]
        public string County
        {
            get
            {
                return _current?.LocCounty;
            }
            set
            {
                _current.LocCounty = value;
            }
        }

        [Category("Location")]
        public string State
        {
            get
            {
                return _current?.LocState;
            }
            set
            {
                _current.LocState = value;
            }
        }

        [Category("WellheadLocation")]
        public double Northing
        {
            get
            {
                return _current?.GeoOffsetNorth ?? 0;
            }
            set
            {
                _current.GeoOffsetNorth = value;
            }
        }

        [Category("WellheadLocation")]
        public double Easting
        {
            get
            {
                return _current?.GeoOffsetEast ?? 0;
            }
            set
            {
                _current.GeoOffsetEast = value;
            }
        }

    }
}
